<?php
/**
 * Created by PhpStorm.
 * User: an
 * Date: 2015/8/20
 * Time: 17:38
 */
namespace Shop\Api;
use Common\Api\Api;
// use Shop\Model\OrderRefundMoneyModel;
use Shop\Model\OrdersModel;
use Shop\Model\OrdersRefundMoneyModel;

class OrderRefundMoneyApi extends  Api{
    const ADD = "Shop/OrderRefundMoney/add";

    const QUERY = "Shop/OrderRefundMoney/query";

	const QUERY_NO_PAGING = "Shop/OrderRefundMoney/queryNoPaging";

    const SAVE_BY_ID = "Shop/OrderRefundMoney/saveById";

    const SAVE = "Shop/OrderRefundMoney/save";

    const DELETE = "Shop/OrderRefundMoney/delete";

    const GET_INFO = "Shop/OrderRefundMoney/getInfo";

    const REFUND_SUCCESS = "Shop/OrderRefundMoney/refundSuccess";

    const WXREFUND_SUCCESS = "Shop/OrderRefundMoney/wxRefundSuccess";

    protected  function _init(){
        $this->model=new OrdersRefundMoneyModel();
    }

    public function refundSuccess($batch_no,$result_data){

        $map = array(
            'batch_no' => $batch_no,
        );

        $entity = array(
            'result_data' => $result_data,
            'result' => 1
        );
        $result = $this->model->where($map)->save($entity);

        if($result){
            return $this->apiReturnSuc('记录成功');
        }else{
            $error = $this -> model -> getDbError();
            return $this->apiReturnErr($error);
        }
    }
//add by zhouzhou
    //微信退款 支持分次
    public function wxRefundSuccess($batch_no,$result_data){

        $map = array(
            'batch_no' => $batch_no,
        );

        $entity = array(
            'result_data' => $result_data,
            'result' => 1
        );
        $result = $this->model->add($entity);

        if($result){
            return $this->apiReturnSuc('记录成功');
        }else{
            $error = $this -> model -> getDbError();
            return $this->apiReturnErr($error);
        }
    }
//end
}
